﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace THUANVV.UI
{
    public partial class frmDemoDataProvider : Form
    {
        public frmDemoDataProvider()
        {
            InitializeComponent();
        }

        private void btnShow_Click(object sender, EventArgs e)
        {
            //1. Khai báo kết nối
            SqlConnection conn = new SqlConnection(@"Data Source=TIMVENGAYHOMWA\SQL2008;Initial Catalog=XUAT_NHAP TON;Persist Security Info=True;User ID=sa;Password=.");

            //2. SqlCommand
            SqlCommand cmd=new SqlCommand("SELECT * FROM KHACHHANG",conn);

            //3. Khai báo Adapter
            SqlDataAdapter da=new SqlDataAdapter(cmd);

            DataTable dt=new DataTable();
            da.Fill(dt);
            dataGridView1.DataSource=dt;

        }
    }
}
